<template>
  <div class="photo-info">
    <van-panel
      :title="imginfo.title"
      :status="'阅读'+imginfo.click"
    >
      <div class="img-box">
        <img
          :src="thumimages.src"
          alt=""
          v-for="(thumimages,index) in thumimages"
          :key="thumimages.id"
          @click="showthums(index)"
        >
      </div>
      <div>{{imginfo.content}}</div>
    </van-panel>
    <comment :id="id"></comment>
  </div>
</template>
<script>
import { ImagePreview } from 'vant'
import comment from '@/components/common'
export default {
  props: ['id'],
  data: () => ({
    imginfo: {},
    thumimages: []
  }),
  methods: {
    async getimageInfo() {
      const res = await this.$http.getimageInfo(this.id)
      this.imginfo = res.message
    },
    async getthumimages() {
      const res = await this.$http.getthumimages(this.id)
      this.thumimages = res.message
    },
    showthums(index) {
      const imgs = []
      this.thumimages.forEach(el => {
        imgs.push(el.src)
      })
      ImagePreview({
        images: imgs,
        startPosition: index
      })
    }
  },
  created() {
    this.getimageInfo()
    this.getthumimages()
  },
  components: {
    comment
  }
}
</script>
<style lang="scss" scoped>
.photo-info {
  .van-cell-group {
    background-color: #fff;
    padding: 0 5px;
  }
  .van-cell {
    height: 42px;
  }
  .van-cell__title {
    font-size: 14px;
    font-weight: 600;
    flex: none;
  }
  .van-panel__content {
    font-size: 12px;
    text-indent: 2.5em;
    line-height: 18px;
  }
  .van-cell__value {
    span {
      font-size: 0.32rem;
      color: red;
    }
  }
  .img-box {
    display: flex;
    justify-content: space-around;
    padding: 4px 0;
    img {
      width: 100px;
      height: 100px;
    }
  }
}
</style>
